#ifndef MAPSQUARE_H
#define MAPSQUARE_H
#include <QLabel>
#include "pixmaps.h"

class MapSquare : public QLabel
{
    Q_OBJECT
public:
    MapSquare(QWidget *parent = nullptr);

    enum UNIT_TYPE{
        UNIT_TYPE_EMPTY = 0,
        UNIT_TYPE_PLAYER1 = 1,
        UNIT_TYPE_PLAYER2 = 2
    };

    enum STATUS{
        STATUS_UNCHECKABLE = -1,
        STATUS_EMPTY = 0,
        STATUS_MOVE = 1,
        STATUS_ATTACK = 2,
    };

    void setStatus(STATUS new_status, bool update_pixmap = true);
    void setUnitType(UNIT_TYPE new_type);
    void setIndex(int r, int c);
    void setSrc(int r = -1, int c = -1);
    void setUnit(void* unit = nullptr);

    STATUS status(){return _status;}
    UNIT_TYPE unit_type(){return _unit_type;}
    int r(){return index_r;}
    int c(){return index_c;}
    int src_r() {return _src_r;}
    int src_c() {return _src_c;}
    void* unit() {return _unit;}
private:
    UNIT_TYPE _unit_type;
    STATUS _status;
    int index_r, index_c;
    int _src_r = -1, _src_c = -1;
    void* _unit = nullptr;
};
#endif // MAPSQUARE_H
